Skip to main content

9.3 - Learning From Other Bots

9.3. Learning From Other Bots

The fastest way to advance your bot is to stand on the shoulders of giants. The StarCraft II AI community thrives on open collaboration, and studying the code and strategies of successful bots is a crucial part of the learning process. By deconstructing the work of others, you can learn new techniques, discover solutions to common problems, and find inspiration for your own unique strategies.


The Open-Source Ecosystem

Your primary resources for finding and studying other bots are the central ladder website and GitHub.

ResourceHow to Use It
SC2 AI Arena Website- Bot Profiles: Many developers link to their bot's public GitHub repository on their profile page.
- Replay Packs: The site regularly releases massive .zip files containing thousands of high-level replays. This is an unparalleled resource for studying the current meta.
GitHub- Topic Search: Search for topics like sc2-ai or python-sc2 to discover public bot repositories.
- Source Code: Directly browse the code of bots you find interesting.
Community Discord- Ask for Code: Many experienced developers are happy to share their repositories if you ask in the #python or #general channels.

The Bot Analysis Workflow

A systematic approach to analysis will yield the best insights.

+------------------------------------+
| 1. Watch Replays (Black Box) | <-- First, understand WHAT the bot does.
| (Form a high-level impression of | What is its strategy? What are its
| its style and strategy.) | strengths and weaknesses?)
+------------------------------------+
|
v
+------------------------------------+
| 2. Read the Code (White Box) | <-- Now, understand HOW it does it.
| (Map behaviors from the replay | Map the bot's actions to specific
| to specific functions/classes.) | lines of code.)
+------------------------------------+
|
v
+------------------------------------+
| 3. Run Locally & Instrument | <-- The deepest level of understanding.
| (Add your own logging and run | Add `print` or `logger` statements
| controlled experiments.) | to see its internal state in real-time.)
+------------------------------------+

Developer's Checklist for Code Analysis

When you have another bot's source code open, use this checklist to guide your exploration.

  • 1. Find the Brain (on_step): Where is the main decision-making loop? How is it structured? (e.g., a long if/elif chain, a state machine, or delegated to manager classes).
  • 2. Deconstruct the Macro Engine:
    • How does it decide when to build workers? Is there a target worker count?
    • What triggers an expansion? Is it based on time, supply, or resources?
    • How does it manage its production queue?
  • 3. Analyze the Micro System:
    • How does it control units in combat? Look for code related to focus firing, kiting, or retreating.
    • Does it have specific logic for handling certain enemy units (e.g., Banelings, Colossi)?
  • 4. Understand the Scouting and Information Gathering:
    • How does it scout? Does it use a dedicated unit or a periodic scan?
    • How does the information it gathers change its behavior? Look for if statements that check for specific enemy units or structures.
  • 5. "Borrow" Concepts, Not Code:
    • The goal is to understand the algorithms and ideas, not to copy-paste code. If you find a clever system, re-implement it in your own architectural style. This ensures you truly understand it and that it fits cleanly into your existing bot.

By treating the library of community bots as an open-source "textbook" of strategies, you can dramatically accelerate your own learning, avoid reinventing the wheel, and integrate state-of-the-art techniques into your own unique creation.